#pragma once
#include "DrawView.h"
namespace UILib
{
    class CDrawScrollBar : public CDrawView
    {
    public:
        CDrawScrollBar(void);
        CDrawScrollBar( HWND hWnd, Bitmap* pBitmap, const PUIRect pRect, const PSplitPos pSplit = NULL,const UINT uID = -1, ViewListener* pListener = NULL );
        virtual ~CDrawScrollBar(void);

        virtual wstring GetClass() { return L"ScrollBar"; };

        void SetBitmap(Bitmap* pbmpBkg, Bitmap* pbmpBtn );
        void SetSilder(Bitmap* pBitmap, const PSplitPos pSplit, const int nOff, const int nStatus = 4 );

        void SetView( const int nView);
        int GetView() const{ return nView_; };

        void SetTotal(const int nTotal );
        int GetTotal() const{ return nTotal_; };

        void SetPos(const int nPos);
        int GetPos()const { return ncurPos_; };

        void Scroll( const int nDistance );

        virtual void HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, HWND hWnd, BOOL& bHandled );
        virtual void DrawElement( const HDC hDC, const RECT &rcPaint );
    protected:
        virtual LRESULT OnLbuttonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnLbuttonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
        virtual LRESULT OnMouseLeave(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

        void CaclSliderRect( RECT& rcSlider );

        void OnFireScroll();
    private:
        HWND        hWnd_;
        Bitmap*     pBitMap_;
        Bitmap*     pBtnBmp_;

        SplitPos    spBkg_;
        SplitPos    spBtn_;

        int         nSliderStatus_;
        int         nOff_;

        int         nTotal_;
        int         nView_;
        int         ncurPos_;

        bool        bInSlider_;
        bool        bDrag_;
        POINT       ptOrg_;
    };
}
